import 'dart:convert';

import '../../entity/artwork_model.dart';
import '../../entity/app_version.dart';

class ArtworkLoader {
  static ArtworkModel load(String json) {
    Map<String, dynamic> jsonMap = jsonDecode(json);
    var ver = AppVersion.fromVersionString(jsonMap['version']);
    if (ver == null) {
      return ArtworkModel.fromJson({});
    }
    switch (ver) {
      case AppVersion.v0_0_1:
        return _loadV0_0_1(jsonMap);
    }
  }

  static ArtworkModel _loadV0_0_1(Map<String, dynamic> jsonMap) {
    return ArtworkModel.fromJson(jsonMap);
  }
}
